<template>
  <div class="home-page">

    <!-- 搜索框 -->
    <div class="input-box">
      <input type="text" placeholder="输入商家" @click="$router.push({ name:'search',params: { shoplist } })" />
    </div>
    <!-- 轮播图 -->
    <Swiper></Swiper>  

    <!-- 店铺列表 -->
    <div class="list">
      <router-link :to="{name:'shopdetail',params: item }" class="item" v-for="(item,index) in shoplist" :key="index">
        <div class="pic">
          <img :src="item.pic" alt="">
        </div>
        <div class="text">
          <div class="name">{{item.name}}</div>
          <div>月售: {{item.buyCount}}</div>
          <div>描述: {{item.desc}}</div>
        </div>
      </router-link>
    </div>
    
    <!-- tabbar组件 -->
    <Tabbar></Tabbar>

  </div>
</template>

<script>

import Axios from 'axios'

export default {
  name: 'home',
  data: function(){
    return {
      shoplist:[]//保存店铺列表
    }
  },
  mounted(){
    Axios.get('/shoplist').then((res)=>{
      this.shoplist = res.data.list;//保存店铺列表数据到 data
      console.log(res.data.list);
      
    })
  },
  components: {
    
  }
}
</script>

<style scoped>
  .input-box{
    background-color: #f0f0f0;
    padding:  20px;
  }
  .input-box input{
    background-color: white;
    width: 100%;
    height: 50px;
    box-sizing: border-box;
    outline: none;
    border: none;
    line-height: 50px;
    border-radius: 25px;
    text-align: center;
  }
  .list .item{
    text-decoration: none;
    color: #333;
    font-size: 14px;
    display: flex;
    margin: 20px ;
  }
  .list .item .pic{
    width: 80px;
    margin-right: 20px;
  }
  .list .item .pic img{
    width: 100%;
  }
  .list .item .text{
    flex: 1;;
  }
  .list .item .text .name{
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
  }
</style>>


